/* Original Author:  Dominick O'Dierno
 * Date: 2007   odiernod@gmail.com     --Originally intended for use with DOMercury:  http://www.odierno.com/domercury
 * Description: A user control to display an IItemContainer from the index, along with its priority
 * 
 * --CHANGELOG--
 * 
 * */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DOMercury.Interfaces;
using DOMercury.Managers;

namespace DOMercury.Forms
{
    public partial class PriorityContainer : UserControl
    {
        private IItemContainer item;
        public PriorityContainer(IItemContainer Item)
        {
            item = Item;
            InitializeComponent();
            nudPriority.Maximum = Convert.ToDecimal(int.MaxValue);
            lblDisplayDesc.Text = item.DisplayDesc;
            lblDisplayName.Text = item.DisplayName;
            lblItemType.Text = item.ItemType;
            nudPriority.Value = Convert.ToDecimal(item.Priority);
           
        }

        private void nudPriority_ValueChanged(object sender, EventArgs e)
        {
            item.Priority = Convert.ToInt32(nudPriority.Value);
        }


        private void pnlIcon_Paint(object sender, PaintEventArgs e)
        {
            Bitmap icon = IconManager.GetIconImage(item.DisplayDesc);
            if (icon != null)
            {
                Graphics g = e.Graphics;
                g.DrawImage(icon, pnlIcon.DisplayRectangle);
            }
        }
    }
}
